from django.db import models

# Create your models here.
from module.models import Module
# from myproject.models import Myproject
from utils.baseModel import BaseModel


class Urls(BaseModel):
    methodType = (
        (1, "GET"),
        (2, "POST"),
        (3, "DELETE"),
        (4, "PUT"),
        (5, "PATCH")
    )

    urls = models.CharField(max_length=200, null=False, verbose_name="请求地址")
    url_name = models.CharField(max_length=50, default=urls)
    method = models.CharField(choices=methodType, null=False, max_length=10)
    describe = models.TextField(max_length=30, default=None, null=True, verbose_name='描述')
    module = models.ForeignKey(to=Module, to_field="id", on_delete=models.CASCADE, verbose_name='所属模块id',
                               default=None, null=False)

    class Meta(object):
        db_table = 'urls'
        ordering = ['-create_time']


class Headers(BaseModel):
    headers_key = models.CharField(max_length=200, null=True, verbose_name="key")
    headers_value = models.CharField(max_length=500, null=True, verbose_name="value")
    urls = models.ForeignKey(to=Urls, to_field="id", on_delete=models.CASCADE, verbose_name="url_id",
                             db_column="url_id", related_name="headers")

    class Meta(object):
        db_table = 'headers'
        ordering = ['-create_time']
